package com.huwaiwai.activemq.demo02.producer.queue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;

/**
 * 生产者实现类
 * Created by huweiwei on 2017/4/28.
 */
@Service
public class ProducerServiceImpl implements ProducerService {
    @Autowired
    @Qualifier("jmsQueueTemplate")
    private JmsTemplate jmsTemplate;

    @Override
    public void sendMessage(Destination destination, String message) {
        System.out.println("-------生产者发送消息------------");
        System.out.println("--------------生产者发了一个消息---------------" + message);
        jmsTemplate.send(destination, (session) -> session.createTextMessage(message));
    }
}
